<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Click History Details - Click Recorder</title>
    <style>
        /* 基础重置 */
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        /* CSS 变量 */
        
         :root {
            --primary-color: #4f46e5;
            --secondary-color: #6b7280;
            --success-color: #059669;
            --danger-color: #dc2626;
            --bg-color: #ffffff;
            --border-color: #e5e7eb;
            --text-color: #111827;
            --text-muted: #6b7280;
            --radius: 8px;
            --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            font-size: 14px;
            line-height: 1.5;
            color: var(--text-color);
            background: #f9fafb;
            padding: 20px;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: var(--bg-color);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            overflow: hidden;
        }
        
        .header {
            background: var(--primary-color);
            color: white;
            padding: 20px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .header h1 {
            font-size: 24px;
            font-weight: 600;
        }
        
        .stats-bar {
            display: flex;
            gap: 30px;
        }
        
        .stat-item {
            text-align: center;
        }
        
        .stat-number {
            font-size: 18px;
            font-weight: 700;
            color: white;
        }
        
        .stat-label {
            font-size: 12px;
            opacity: 0.8;
        }
        
        .controls {
            padding: 20px 30px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 15px;
        }
        
        .search-box {
            display: flex;
            gap: 10px;
            align-items: center;
        }
        
        .search-input {
            padding: 8px 12px;
            border: 1px solid var(--border-color);
            border-radius: var(--radius);
            font-size: 14px;
            width: 250px;
        }
        
        .search-input:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
        }
        
        .filter-buttons {
            display: flex;
            gap: 10px;
        }
        
        .btn {
            padding: 8px 16px;
            border: 1px solid var(--border-color);
            border-radius: var(--radius);
            background: white;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .btn:hover {
            background: #f9fafb;
        }
        
        .btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
        
        .btn.active {
            background: var(--primary-color);
            color: white;
            border-color: var(--primary-color);
        }
        
        .btn-primary {
            background: var(--primary-color);
            color: white;
            border-color: var(--primary-color);
        }
        
        .btn-primary:hover {
            background: #3730a3;
        }
        
        .btn-danger {
            background: var(--danger-color);
            color: white;
            border-color: var(--danger-color);
        }
        
        .btn-danger:hover {
            background: #b91c1c;
        }
        
        .table-container {
            overflow-x: auto;
            max-height: 600px;
            overflow-y: auto;
        }
        
        .history-table {
            width: 100%;
            border-collapse: collapse;
        }
        
        .history-table th,
        .history-table td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid var(--border-color);
        }
        
        .history-table th {
            background: #f9fafb;
            font-weight: 600;
            color: var(--text-color);
            position: sticky;
            top: 0;
            z-index: 10;
        }
        
        .history-table tbody tr:hover {
            background: #f9fafb;
        }
        
        .time-cell {
            font-weight: 500;
            color: var(--text-color);
            white-space: nowrap;
            min-width: 140px;
        }
        
        .domain-cell {
            color: var(--primary-color);
            font-weight: 500;
            min-width: 120px;
        }
        
        .element-cell {
            font-family: 'Monaco', 'Consolas', monospace;
            font-size: 12px;
            color: var(--text-muted);
            max-width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .text-cell {
            max-width: 150px;
            overflow: hidden;
            text-overflow: ellipsis;
            font-style: italic;
            color: var(--text-color);
        }
        
        .position-cell {
            font-family: 'Monaco', 'Consolas', monospace;
            font-size: 12px;
            color: var(--text-muted);
            white-space: nowrap;
        }
        
        .url-cell {
            max-width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .url-cell a {
            color: var(--primary-color);
            text-decoration: none;
            font-size: 12px;
        }
        
        .url-cell a:hover {
            text-decoration: underline;
        }
        
        .loading {
            padding: 40px;
            text-align: center;
            color: var(--text-muted);
        }
        
        .no-data {
            padding: 40px;
            text-align: center;
            color: var(--text-muted);
        }
        
        .pagination {
            padding: 20px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-top: 1px solid var(--border-color);
        }
        
        .page-info {
            color: var(--text-muted);
            font-size: 14px;
        }
        
        .page-controls {
            display: flex;
            gap: 10px;
            align-items: center;
        }
        
        .page-input {
            width: 60px;
            padding: 4px 8px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            text-align: center;
            font-size: 12px;
        }
        
        .export-section {
            padding: 20px 30px;
            border-top: 1px solid var(--border-color);
            background: #f9fafb;
        }
        
        .export-buttons {
            display: flex;
            gap: 10px;
            justify-content: center;
            flex-wrap: wrap;
        }
        /* 响应式设计 */
        
        @media (max-width: 768px) {
            body {
                padding: 10px;
            }
            .container {
                margin: 0;
            }
            .header {
                padding: 15px 20px;
                flex-direction: column;
                gap: 15px;
            }
            .stats-bar {
                gap: 20px;
            }
            .controls {
                padding: 15px 20px;
                flex-direction: column;
                align-items: stretch;
            }
            .search-input {
                width: 100%;
            }
            .filter-buttons {
                justify-content: center;
                flex-wrap: wrap;
            }
            .table-container {
                max-height: 400px;
            }
            .history-table th,
            .history-table td {
                padding: 8px 12px;
            }
            .pagination {
                padding: 15px 20px;
                flex-direction: column;
                gap: 10px;
            }
            .export-buttons {
                flex-direction: column;
            }
        }
        /* 滚动条样式 */
        
        .table-container::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }
        
        .table-container::-webkit-scrollbar-track {
            background: #f1f5f9;
        }
        
        .table-container::-webkit-scrollbar-thumb {
            background: var(--border-color);
            border-radius: 4px;
        }
        
        .table-container::-webkit-scrollbar-thumb:hover {
            background: var(--secondary-color);
        }
    </style>
</head>

<body>
    <div class="container">
        <!-- 页面头部 -->
        <div class="header">
            <h1>Click History Details</h1>
            <div class="stats-bar">
                <div class="stat-item">
                    <div class="stat-number" id="totalClicks">0</div>
                    <div class="stat-label">Total Clicks</div>
                </div>
                <div class="stat-item">
                    <div class="stat-number" id="dailyClicks">0</div>
                    <div class="stat-label">Today's Clicks</div>
                </div>
                <div class="stat-item">
                    <div class="stat-number" id="displayedClicks">0</div>
                    <div class="stat-label">Displayed Records</div>
                </div>
            </div>
        </div>

        <!-- 控制面板 -->
        <div class="controls">
            <div class="search-box">
                <input type="text" class="search-input" id="searchInput" placeholder="Search domain, element or text content...">
                <button class="btn btn-primary" id="searchBtn">Search</button>
                <button class="btn" id="clearSearchBtn">Clear</button>
            </div>

            <div class="filter-buttons">
                <button class="btn active" id="filterAll">All</button>
                <button class="btn" id="filterToday">Today</button>
                <button class="btn" id="filterYesterday">Yesterday</button>
                <button class="btn" id="filterWeek">This Week</button>
            </div>
        </div>

        <!-- 数据表格 -->
        <div class="table-container">
            <table class="history-table">
                <thead>
                    <tr>
                        <th>Time</th>
                        <th>Domain</th>
                        <th>Element</th>
                        <th>Text Content</th>
                        <th>Position</th>
                        <th>Page URL</th>
                    </tr>
                </thead>
                <tbody id="historyTableBody">
                    <tr>
                        <td colspan="6" class="loading">Loading...</td>
                    </tr>
                </tbody>
            </table>
        </div>

        <!-- 分页 -->
        <div class="pagination">
            <div class="page-info" id="pageInfo">
                Showing 0 - 0 of 0 records
            </div>
            <div class="page-controls">
                <button class="btn" id="prevPageBtn">Previous</button>
                <span>Page</span>
                <input type="number" class="page-input" id="pageInput" value="1" min="1">
                <span id="totalPagesSpan">/ 1</span>
                <button class="btn" id="nextPageBtn">Next</button>
                <button class="btn" id="goPageBtn">Go</button>
            </div>
        </div>

        <!-- 导出功能 -->
        <div class="export-section">
            <div class="export-buttons">
                <button class="btn btn-primary" id="exportJsonBtn">Export JSON</button>
                <button class="btn btn-primary" id="exportCsvBtn">Export CSV</button>
                <button class="btn" id="refreshBtn">Refresh Data</button>
                <button class="btn btn-danger" id="clearAllBtn">Clear All Data</button>
            </div>
        </div>
    </div>

    <script src="history.js"></script>
</body>

</html>